package com.stephen.dubbo.controller;

import com.stephen.dubbo.entity.Product;
import com.stephen.dubbo.entity.User;
import com.stephen.dubbo.service.ProductService;
import com.stephen.dubbo.service.UserService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by ssc on 2021-02-28 21:39 .
 * Description: dubbo2.7.0及之前版本,使用@Reference,2.7.0之后版本使用@DubboReference
 */
@RestController
public class ProductController {

    // @Reference
    @DubboReference
    private ProductService productService;
    @DubboReference
    private UserService userService;

    @RequestMapping("/getProduct/{id}")
    public Product getProduct(@PathVariable Long id) {
        return productService.get(id);
    }

    @RequestMapping("/getUser/{id}")
    public User getUser(@PathVariable Integer id) {
        return userService.getUser(id);
    }

}
